// massidll.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "massi.h"
#include <time.h>

__declspec(dllexport) Massilaskuri::Massilaskuri(double palkka) 
{
	this->palkka = palkka / 3600;
	this->aika = 0;
	this->kello = 0;
	this->taika = 0;
	stopped = false;
}

__declspec(dllexport) double Massilaskuri::calcPalkka(void) 
{
	return this->palkka * (double)this->aika;
}

__declspec(dllexport) void Massilaskuri::updateLaskuri(void)
{
	if(!this->stopped) {
		time_t timer;
		if(kello == 0) {
			time_t timer;
			this->kello = time(&timer);
		}

		this->aika = time(&timer) - this->kello + this->taika;
		
	}
}

__declspec(dllexport) void Massilaskuri::prLaskuri(void)
{
	if(!stopped)
	{
		this->stopped = true;
		this->taika = this->aika;
	}else {
		time_t timer;
		this->kello = time(&timer);
		this->stopped = false;
	}

}

